package com.zshan.clinic.common.enums;


import com.zshan.clinic.common.util.string.StringUtil;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 打印大类
 */
public enum PrintTypeEnum {

    // 文书类（categoryCode = "1"）
    MEDICAL_RECORD("1", "病历", PrintCategoryEnum.DOCUMENT.getValue()),
    EXAM_REQUEST("2", "检查申请单", PrintCategoryEnum.DOCUMENT.getValue()),
    DRUG_PRESCRIPTION("3", "成药处方", PrintCategoryEnum.DOCUMENT.getValue()),
    HERB_PRESCRIPTION("4", "中药处方", PrintCategoryEnum.DOCUMENT.getValue()),
    EXTERNAL_PRESCRIPTION("5", "外治处方", PrintCategoryEnum.DOCUMENT.getValue()),
    INFUSION_PRESCRIPTION("6", "输液处方", PrintCategoryEnum.DOCUMENT.getValue()),
//    DISPENSE_DETAIL("7", "发药明细", PrintCategoryEnum.DOCUMENT.getValue()),

    // 票据类（categoryCode = "2"）
    REGISTRATION_RECEIPT("8", "挂号小票", PrintCategoryEnum.RECEIPT.getValue()),
    PAYMENT_RECEIPT("9", "收费小票", PrintCategoryEnum.RECEIPT.getValue());

    private String value;
    private String text;
    private String categoryCode;

    private PrintTypeEnum(String value, String text,String categoryCode) {
        this.value = value;
        this.text = text;
        this.categoryCode = categoryCode;
    }

    public static List<String> getRxList(){
        List<String> rxList = new ArrayList<>();
        rxList.add(DRUG_PRESCRIPTION.getValue());
        rxList.add(HERB_PRESCRIPTION.getValue());
        rxList.add(EXTERNAL_PRESCRIPTION.getValue());
        rxList.add(INFUSION_PRESCRIPTION.getValue());
        return rxList;
    }


    public String getValue() {
        return this.value;
    }

    public String getText() {
        return this.text;
    }

    public String getCategoryCode() {
        return categoryCode;
    }

    public static PrintTypeEnum getValue(String value) {
        if(StringUtil.isBlank(value)){
            return null;
        }
        PrintTypeEnum [] arr$ = values();
        int len$ = arr$.length;
        for(int i$ = 0; i$ < len$; ++i$) {
            PrintTypeEnum dot = arr$[i$];
            if (value.equals(dot.getValue())) {
                return dot;
            }
        }
        return null;
    }

    public static String getText(String value) {
        if(StringUtil.isBlank(value)){
            return null;
        }
        PrintTypeEnum[] arr$ = values();
        int len$ = arr$.length;
        for(int i$ = 0; i$ < len$; ++i$) {
            PrintTypeEnum dot = arr$[i$];
            if (value.equals(dot.getValue())) {
                return dot.getText();
            }
        }
        return null;
    }

    public static boolean isValue(String value) {
        if(StringUtil.isBlank(value)){
            return false;
        }
        PrintTypeEnum[] arr$ = values();
        int len$ = arr$.length;
        for(int i$ = 0; i$ < len$; ++i$) {
            PrintTypeEnum dot = arr$[i$];
            if (value.equals(dot.getValue())) {
                return true;
            }
        }
        return false;
    }

    public Map toMap() {
        Map map = new HashMap();
        map.put("value", this.value);
        map.put("text", this.text);
        map.put("categoryCode", this.categoryCode);
        return map;
    }

    public static List<Map> allToMap() {
        List<Map> list = new ArrayList();
        PrintTypeEnum[] arr$ = values();
        int len$ = arr$.length;
        for(int i$ = 0; i$ < len$; ++i$) {
            PrintTypeEnum dot = arr$[i$];
            list.add(dot.toMap());
        }
        return list;
    }
}
